package com.engine.shunsheng.controller;

import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.shunsheng.service.SalaryService;
import com.engine.shunsheng.service.impl.SalaryServiceImpl;
import com.google.gson.Gson;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;

/**
 * @author chenwnj
 * @date 2023/11/16
 * @description
 **/
public class SalaryController {

    public SalaryService getSalaryService(User user) {
        return ServiceUtil.getService(SalaryServiceImpl.class,user);
    }

    @GET
    @Path("/getSalaryInfo")
    @Produces(MediaType.APPLICATION_JSON)
    public String getSalaryInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getSalaryService(user).getSalaryInfo(params);
        return new Gson().toJson(resultDatas);
    }

}
